<?php
require_once "../database/mysql.class.php";
//DAO对象，对数据库操作
//对应用户表，用户的增删改查

class ridegamerdao{

	private $db;

	public function __construct(){
		$this->db=new mysql();
	}
	
	public function Chaxun($ridegamerid=null){	
		if (!isset($ridegamerid)){
			$sql="select * from ridegamer order by id;";
			return $this->db->query($sql);
		}
		else if (isset($ridegamerid)){
			$sql="select *  from ridegamer  where id like '{$ridegamerid}%' order by id;";
		    return $this->db->query($sql);
		}
		else {
			
		}
	}
	//添加骑士
	public function Tian($ming,$level,$zuo,$jia,$img){//
		// && isset($ming) && isset($level) && isset($zuo) && isset($jia)
			$sql=" INSERT INTO ridegamer VALUES(null,'".$ming."',".$level.",'".$zuo."',".$jia.",'".$img."');";//'< src=/'../../qian/".$img."/'>'
			return $this->db->inser($sql);
			header("location:../view/main.php?url=ridegamer.php");
		
	}
	//修改骑士
	public function Xiugai($ridegamerid,$ming,$zuo,$jia){
		if (isset($ming) || isset($zuo) || isset($jia) ){
			$sql=" UPDATE  ridegamer SET rname='".$ming."' ,degree='".$zuo."' ,price='".$jia."' WHERE id=".$ridegamerid.";";
			return $this->db->update($sql);
			header("location:../view/main.php?url=ridegamer.php");
		}
	
	}
	//删除骑士
	public function Del($delid){
		if (isset($delid)){
			//echo($delid);
			$sql=" DELETE FROM ridegamer WHERE id=".$delid.";";
			return $this->db->delete($sql);
			header("location:../view/main.php?url=gongao.php");
		}
	
	}
	
}
?>